<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}AI Chat{% endblock %}</title>
    {% load static %}
    <link rel="stylesheet" href="{% static 'css/style.css' %}">
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        :root {
            --primary: #4361ee;
            --secondary: #3f37c9;
            --accent: #4895ef;
            --dark: #1d1e2c;
            --darker: #121420;
            --light: #f8f9fa;
            --gray: #6c757d;
            --success: #4cc9f0;
            --warning: #f72585;
            --card-bg: rgba(255, 255, 255, 0.05);
            --border-radius: 12px;
            --transition: all 0.3s ease;
        }

        body {
            background: linear-gradient(135deg, var(--darker), var(--dark));
            color: var(--light);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* 头部导航 */
        header {
            background-color: rgba(18, 20, 32, 0.95);
            backdrop-filter: blur(10px);
            padding: 1rem 0;
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        nav ul {
            display: flex;
            justify-content: flex-end;
            list-style: none;
            padding: 0 2rem;
            max-width: 1200px;
            margin: 0 auto;
        }

        nav ul li {
            margin-left: 1.5rem;
        }

        nav ul li a {
            color: var(--light);
            text-decoration: none;
            font-weight: 500;
            padding: 0.5rem 1rem;
            border-radius: 30px;
            transition: var(--transition);
            display: inline-block;
        }

        nav ul li a:hover {
            background-color: var(--primary);
            transform: translateY(-2px);
        }

        /* 用户相关链接样式 */
        nav ul li:last-child a {
            background-color: var(--warning);
        }

        /* 消息提示 */
        #messages {
            max-width: 1200px;
            margin: 1rem auto 0;
            padding: 0 1.5rem;
        }

        .alert {
            padding: 1rem;
            border-radius: var(--border-radius);
            margin-bottom: 1rem;
            background-color: rgba(76, 201, 240, 0.15);
            border: 1px solid var(--success);
            color: var(--light);
        }

        .alert.success {
            background-color: rgba(76, 201, 240, 0.15);
            border-color: var(--success);
        }

        .alert.error {
            background-color: rgba(247, 37, 133, 0.15);
            border-color: var(--warning);
        }

        /* 主体内容 */
        main {
            flex: 1;
            max-width: 1200px;
            width: 100%;
            margin: 2rem auto;
            padding: 0 1.5rem;
        }

        /* 页脚 */
        footer {
            background-color: rgba(18, 20, 32, 0.95);
            text-align: center;
            padding: 1.5rem 0;
            margin-top: auto;
            color: var(--gray);
            font-size: 0.9rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            nav ul {
                justify-content: center;
                padding: 0 1rem;
                flex-wrap: wrap;
            }

            nav ul li {
                margin: 0.5rem;
            }

            main {
                padding: 0 1rem;
            }
        }
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <header>
        <nav>
            <ul>
                {% if user.is_authenticated %}
                    <li><a href="{% url 'Chat:room_list' %}">聊天室列表</a></li>
                    <li><a href="{% url 'User:logout' %}">登出 ({{ user.username }})</a></li>
                {% else %}
                    <li><a href="{% url 'User:login' %}">登录</a></li>
                    <li><a href="{% url 'User:register' %}">注册</a></li>
                {% endif %}
            </ul>
        </nav>
    </header>

    <div id="messages">
        {% if messages %}
            {% for message in messages %}
                <div class="alert {% if message.tags %}{{ message.tags }}{% endif %}">
                    {{ message }}
                </div>
            {% endfor %}
        {% endif %}
    </div>

    <main>
        {% block content %}
        <!-- 子模板内容会替换这里 -->
        {% endblock %}
    </main>

    <footer>
        <p>&copy; 2025 AI Chat - 让沟通更智能</p>
    </footer>

    <script src="{% static 'js/main.js' %}"></script>
</body>
</html>